package net.protocol.diameter.dictionary;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author jinhongw@gmail.com
 */
public class DiameterFormatFactory {
    private static final Map<String, MessageFormatFactory>
            MFFS = new HashMap<String, MessageFormatFactory>();

    private static final Map<String, AVPFormatFactory>
            AFFS = new HashMap<String, AVPFormatFactory>();;

    /**
     * @param key key with which the specified <tt>MessageFormatFactory</tt> is to be associated
     * @param factory A specified implementation of the <tt>MessageFormatFactory</tt> interface
     * @return This MessageFormatFactory
     */
    public static MessageFormatFactory register(String key, MessageFormatFactory factory) {
        MFFS.put(key, factory);
        return factory;
    }

    /**
     * @param key key with which the specified <tt>AvpFormatFactory</tt> is to be associated
     * @param factory A specified implementation of the <tt>AvpFormatFactory</tt> interface
     * @return This AvpFormatFactory
     */
    public static AVPFormatFactory register(String key, AVPFormatFactory factory) {
        AFFS.put(key, factory);
        return factory;
    }

    /**
     * @param key the key whose associated <tt>MessageFormatFactory</tt> is to be returned
     * @return A specified implementation of the <tt>MessageFormatFactory</tt> interface
     */
    public static MessageFormatFactory getMessageFormatFactory(String key) {
      return MFFS.get(key);
    }

    /**
     * @param key the key whose associated <tt>AvpFormatFactory</tt> is to be returned
     * @return A specified implementation of the <tt>AvpFormatFactory</tt> interface
     */
    public static AVPFormatFactory getAvpFormatFactory(String key) {
        return AFFS.get(key);
    }
}

